<?php

namespace app\install\service\install\observer;

use app\common\util\base\BaseObserver;
use app\common\util\base\BaseServer;
use app\model\User;
use think\facade\Config;
use think\facade\Db;
use think\facade\Env;

class CreateAdminObserver extends BaseObserver
{
    protected array $data = [];

    public function setData(array $data) {
        $this->data = $data;
        return $this;
    }

    public function handle(BaseServer $server = null)
    {
        $data = $this->data;
        $model = new User();
        $user = $model->table('v_user')->save([
            'username'=>$data['phone'],
            'password'=>md5($data['adminPassword'])
        ]);
        return $user;
    }
}